<template>
  <view class="page">
    <map :style="{ height: windowHeight, width: windowWidth }" name="">
      <cover-image
        @click="openDetails"
        class="search-icon"
        :src="require('@/static/img/headwaters-search-btn.png')"
      ></cover-image>
      <view @click="gotoPage('/pages/headwaters/add')" class="btn-icon">
        <text class="btn-text">新增水源</text>
      </view>
      <cover-view v-if="show" :style="{ width: windowWidth }" class="detalis">
        <cover-view class="detalis-title">深圳公仔岩水源</cover-view>
        <text class="detalis-address"
          >180m² 广东省深圳市南山区人民路公仔岩180号</text
        >
        <cover-view class="detalis-pics">
          <cover-image
            class="detalis-pic"
            src="https://img2.baidu.com/it/u=840015729,3491529512&fm=253&fmt=auto&app=138&f=JPEG?w=631&h=500"
          ></cover-image>
          <cover-image
            class="detalis-pic"
            src="https://img2.baidu.com/it/u=1316391147,4123903154&fm=253&fmt=auto&app=138&f=JPEG?w=704&h=500"
          ></cover-image>
          <cover-image
            class="detalis-pic"
            src="https://img2.baidu.com/it/u=840015729,3491529512&fm=253&fmt=auto&app=138&f=JPEG?w=631&h=500"
          ></cover-image>
        </cover-view>
        <view class="btn" @click="gotoPage('/pages/headwaters/details')"
          ><text class="btn-text">查看详情</text></view
        >
      </cover-view>
    </map>
  </view>
</template>

<script>
export default {
  data() {
    return {
      show: false,
      windowHeight: uni.getSystemInfoSync.windowHeight,
      windowWidth: uni.getSystemInfoSync.windowWidth,
    };
  },
  onLoad() {
    this.windowHeight = uni.getSystemInfoSync().windowHeight;
    this.windowWidth = uni.getSystemInfoSync().windowWidth;
  },
  methods: {
    gotoPage(value) {
      uni.navigateTo({
        url: value,
      });
    },
    openDetails() {
      this.show = !this.show;
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  position: relative;
}
.search-icon {
  position: absolute;
  top: 30rpx;
  right: 30rpx;
  width: 207rpx;
  height: 70rpx;
}
.btn-icon {
  position: absolute;
  left: 147rpx;
  bottom: 70rpx;
  width: 456rpx;
  height: 81rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 53rpx;
  background-color: #00beff;
  &-text {
    color: #ffffff;
    font-size: 32rpx;
    font-weight: 400;
  }
}
.detalis {
  position: absolute;
  left: 0;
  bottom: 0;
  background: #ffffff;
  border-radius: 28rpx 28rpx 0 0;
  box-sizing: border-box;
  padding: 49rpx 30rpx 0;
  &-title {
    font-size: 32rpx;
    font-weight: bold;
    color: #202020;
    margin: 21rpx 0;
  }
  &-address {
    font-size: 26rpx;
    color: #666666;
    margin-bottom: 42rpx;
  }
  &-pics {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
  }
  &-pic {
    width: 182rpx;
    height: 182rpx;
    margin-right: 47rpx;
    margin-bottom: 47rpx;
    border-radius: 18rpx;
  }
}
.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 456rpx;
  height: 81rpx;
  border-radius: 53rpx;
  background: #00beff;
  margin-left: 120rpx;
  margin-bottom: 70rpx;

  &-text {
    color: #ffffff;
    font-size: 32rpx;
    font-weight: 400;
  }
}
</style>
